﻿using BasicInformation.API.Application.Command.OutsourcingCommand;
using BasicInformation.API.Application.Command.OwnerCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformation.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OutsourcingController : ControllerBase
    {
        private readonly IMediator mediator;

        public OutsourcingController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 外协单位新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> OutsourcingAdd(OutsourcingCreateCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 外协单位删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> OwnerDelete([FromQuery] OutsourcingDeleteCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 外协单位批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> OutsourcingBatchDelete([FromQuery] OutsourcingBatchDeleteCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 外协单位修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> OutsourcingUpdate(OutsourcingUpdateCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
